package bank;

import cash_access.OverdraftException;


/**
 * Class for an Account
 */
public class Account extends cash_access.Account {
	private String ID; // Account ID
	private double balance;  // Account State
	
	public Account(String id) {
		// Initialize
		ID = id;
		balance = 0.0;		
	}
	
	/**
	 * returns the ID of this Account
	 * (Will be used for the GUI)
	 * 
	 * @return Account ID
	 */
	protected String getID() {
		return ID;
	}

	@Override
	public void deposit(double amount) {
		balance+=amount;
	}

	@Override
	public void withdraw(double amount) throws OverdraftException {
		// TODO Auto-generated method stub
		//check if there's enough money on the Account
		if(amount>0 && balance>0.0 && amount<=balance)
		{
			balance-=amount;
		}
		else
		{
			throw new OverdraftException("There's not enough money on the Account");
		}
		
	}

	@Override
	public double getBalance() {
		return balance;
	}
}
